home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / math / graphs / graphed-.1 / graphed- / usr / local / graphed / include / sgraph / std.h < prev   
Encoding:
C/C++ Source or Header  |  1995-07-10  |  1.9 KB  |  115 lines

  1. /* (C) Universitaet Passau 1986-1994 */
  2. /* Sgraph Source, 1988-1994 by Michael Himsolt */
  3.  
  4. #ifndef STD
  5. #define STD
  6.  
  7. /*
  8. #define SGRAPH_STANDALONE
  9. */
  10.  
  11. #ifdef SGRAPH_STANDALONE
  12. #undef GRAPHED
  13. #endif
  14.  
  15.  
  16. #include <assert.h>
  17. #include <stdio.h>
  18. #ifndef __GNUC__
  19. #ifndef MALLOC_HEADER
  20. #define MALLOC_HEADER
  21. #include <malloc.h>
  22. #endif
  23. #else
  24. #include <malloc.h>
  25. #endif
  26.  
  27. #define    nil    NULL
  28.  
  29. #ifndef TRUE
  30. #define TRUE    (0==0)
  31. #endif
  32. #ifndef FALSE
  33. #define    FALSE    (0==1)
  34. #endif
  35.  
  36. #define    true    TRUE
  37. #define    false    FALSE
  38.  
  39. #ifndef iif
  40. #define    iif(b,e1,e2)    ((b) ? (e1) : (e2))
  41. #endif
  42. #ifndef maximum
  43. #define    maximum(x,y)    iif ((x) > (y), (x), (y))
  44. #endif
  45. #ifndef minimum
  46. #define    minimum(x,y)    iif ((x) < (y), (x), (y))
  47. #endif
  48.  
  49. #ifndef bool
  50. #define    bool    int
  51. #endif
  52. #ifndef Local
  53. #define    Local    static
  54. #endif
  55. #ifndef Global
  56. #define    Global
  57. #endif
  58.  
  59. typedef    void (*Pointer_to_procedure)();
  60.  
  61. typedef    struct    attributes {
  62. /*    char    *key; */
  63.     union    {
  64.         int    integer;
  65.         char    *data;
  66.     }
  67.         value;
  68. }
  69.     Attributes;
  70.  
  71. #define    attr_flags(x)        ((x)->attrs.value.integer)
  72. #define    attr_int(x)        ((x)->attrs.value.integer)
  73. #define    attr_data(x)        ((x)->attrs.value.data)
  74. #define    attr_data_of_type(x,t)    ((t)attr_data(x))
  75. #define    set_attr_data(x, v)    (attr_data(x)=(char*)v)
  76.  
  77. #if FALSE
  78. #define attr_key(x)        ((x)->attrs.key)
  79. #endif
  80.  
  81. typedef    enum {
  82.     ATTR_INTEGER,
  83.     ATTR_DATA
  84. #if FALSE
  85.     /* The following two are unused ... */
  86.     ,ATTR_KEY_INTEGER,
  87.     ATTR_KEY_DATA
  88. #endif
  89. }
  90.     Attributes_type;
  91.  
  92. #define ATTR_FLAGS ATTR_INTEGER
  93.  
  94. extern    Attributes    make_attr (Attributes_type attr_type, ...);
  95.  
  96. extern    char    *strsave(char *s);
  97. extern    char    *strnsave(char *s, int len);
  98.  
  99. #ifndef GRAPHED
  100. #ifndef SGRAPH_STANDALONE
  101. extern    char    *mymalloc (unsigned int size);
  102. extern    char    *mycalloc (unsigned int n, unsigned int size);
  103. extern    void    myfree   ();
  104.  
  105. #endif
  106. #endif
  107.  
  108. #ifdef SGRAPH_STANDALONE
  109. #define mymalloc(s)   malloc(s)
  110. #define mycalloc(n,s) calloc((n),(s))
  111. #define myfree(s)     free(s)
  112. #endif
  113.  
  114. #endif
  115.